#include <stdio.h>
int Days(int(*p)[],int year, int month)
{
	int day = (*p)[month];
	if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
	{
		if (month == 2)
		{
			day++;
		}
	}
	return day;
}
int main()
{
	int year = 0;
	int month = 0;
	int arr[] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
	scanf_s("%d%d", &year, &month);
	int day=Days(arr,year, month);
	printf("%d\n", day);
	return 0;
}